package LineCode.剑指Offer.Utils;


import LineCode.剑指Offer.dto.ListNode;

public class ListNodeUtil {

    public static ListNode makeListNode (int[] nums) {
        if (nums == null || nums.length <= 0)
            return null;
        ListNode result = new ListNode(nums[0]);
        ListNode index = result;
        for (int i = 1; i < nums.length; i++) {
            index.next = new ListNode(nums[i]);
            index = index.next;
        }
        return result;
    }

    public static void printListNode (ListNode listNode) {
        while (listNode != null) {
            System.out.print(listNode.val + ", ");
            listNode = listNode.next;
        }
        System.out.println();
    }


}

